const counter = {
  namespaced: true, // 模块化, 开启命名空间, 防止命名冲突
  state: {
    counter: 0
  },
  mutations: {
    incrementCount(state) {
      state.counter++
    }
  },
  actions: {
    incrementCountAction(context) {
      context.commit('incrementCount')
    }
  },
  getters: {
    // 1. state: 当前模块的state
    // 2. getters: 当前模块的getters
    // 3. rootState: 根模块的state
    doubleCount(state, getters, rootState) {
      return state.counter + rootState.rootCounter
    }
  }
}

export default counter